<%@page language="java" import="com.scalar.chiptrack.operations.LotView, 
                                java.util.ArrayList, 
                                java.util.Iterator,
                                com.scalar.chiptrack.utils.ConfigManager,
                                com.scalar.chiptrack.engineering.dao.EngineeringDAO"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/jsp/operations/split_merge_lots.jsp"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
 <%  //System.out.println(request.getAttribute("marketingProducts"));
    //System.out.println(request.getAttribute("processSteps"));
    //System.out.println(request.getAttribute("showList"));
    //System.out.println(request.getAttribute("from"));
 %>


<SCRIPT language="JavaScript1.2">
 function submitPage(tempAction)
 {
        var pa=document.getElementById("message");
        //alert("tempaction = "+ tempAction);

        if(tempAction == 'UPDATE')
            document.splitMergeLot.lotaction.value = "Update";
        else if(tempAction == "LOT_SEARCH"){
            var x = document.splitMergeLot.partNumber;
            for(var i = 0; i<x.length; i++){
                if(x.options[i].selected){
                        if((x.options[i].value == "Select Product")||(x.options[i].value =="") ){
                                x.options[i].value = 0;
		    	}
                }
            }
            document.splitMergeLot.lotaction.value = tempAction;
        }

        document.splitMergeLot.submit();
 }

 function changeProcessStep(){
 	var temp_process = document.splitMergeLot.processStep;
    document.splitMergeLot.lotaction.value = 'LOAD_PRODUCTS';
 	for(var i=0; i<temp_process.length; i++){
 		if(temp_process.options[i].selected){
 			//alert(temp_process.options[i].value);
 			document.splitMergeLot.process.value = temp_process.options[i].value;
 			document.splitMergeLot.submit();
 		}
 	}

 }

 function splitLot(lotId, status, lotNum){

 		document.splitMergeLot.lotaction.value = 'LOT_SPLIT';
        document.splitMergeLot.lotid.value = lotId;
        document.splitMergeLot.status.value = status;
        document.splitMergeLot.tempLotNumber.value = lotNum;
        document.splitMergeLot.submit();
 }

  function mergeLot(lotId, status, lotNum){

 	document.splitMergeLot.lotaction.value = 'LOT_MERGE';
        document.splitMergeLot.lotid.value = lotId;
        document.splitMergeLot.status.value = status;
        document.splitMergeLot.tempLotNumber.value = lotNum;

        document.splitMergeLot.submit();
 }
</SCRIPT>
</HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%@include file="/jsp/operations/operations_menu.jsp" %>
</TD>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<html:form name="splitMergeLot"  type="com.scalar.chiptrack.operations.process.forms.SplitMergeForm" action="/splitMergeLot.do">
<center><span class="NArialW">Split/Merge Lots </span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
	<center>
	<strong><font face="Verdana" size="-5" align="center" color="#ff0000" id="message"></font>
	</center>
<%
	String message = (String)request.getAttribute("errorMessage");
   	if(message==null)
   		message="";
%>
<%
 	if(!message.equals("")){
%>
<!--<p align ="center">
<strong><font face="Verdana" size="-5" align="center" color="#ff0000"><b><%=message%></b></font>
</p> -->
    <SCRIPT language="JavaScript1.2">
    	var pa=document.getElementById("message");
    	pa.innerHTML = "<%= message%>";
    </SCRIPT>
<%
 	}
 %>

<!-- from here your body starts -->

<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
<%
        String from = (String)request.getAttribute("from");
%>

<table border="0" width="90%" align=right>
 <tr>
     <td>
	 <table border="0" width="100%" align=right>
         <tr><td colspan =6  class="NArialL"><chiptrack:errors styleClass="NArialL"  /></td></tr>
         <tr><td colspan =6  class="NArialL"><chiptrack:info styleClass="NArialL" /></td></tr>
         <tr><td colspan =6  class="NArialL">&nbsp</td></tr>
 	     <tr>
 	     	<td width="10%"><font class="NArialL">Process Steps</font></td>
  	  		<td width="15%"><font class="NArialL">
  	  			<html:select name="splitMergeLot" property="processStep" styleClass="txfield" onchange="javascript:changeProcessStep()">
      	    		<%--<html:option value="All Process" />--%>
                    <html:option value="">Select Any Process</html:option>
            		<%-- <html:options collection="processSteps" property="value" labelProperty="label"/> --%>
                        <html:option value="FAB"> FAB </html:option>
                        <html:option value="SORT"> SORT </html:option>
                        <html:option value="Assembly"> ASSEMBLY </html:option>
                        <html:option value="TEST"> TEST </html:option>
                        <html:option value="Wafer Store"> WAFER STORE </html:option>
                        <%--<html:option value="Die Bank"> DIE BANK </html:option>--%>
                        <html:option value="Class Store"> CLASS STORE </html:option>
                        <html:option value="Mark & Pack"> MARK & PACK </html:option>
                        <html:option value="Finished Goods"> FINISHED GOODS </html:option>
        	    </html:select>
  	  		</td>
  	  		<td width="5%">&nbsp;</td>
       		<td width="10%"><font class="NArialL">Product Name</font></td>
       		<td width="15%"><font class="NArialL">
        	    <html:select name="splitMergeLot" property="partNumber" styleClass="txfield">
      	    		<html:option value="Select Product" />
            		<html:options collection="marketingProducts" property="value" labelProperty="label"/>
        	    </html:select>
			</td>
       		<td width="5%">&nbsp;</td>
     	  </tr>
     	  <tr>
       		<td width="10%"><font class="NArialL">Lot Number</font></td>
       		<td width="15%"><font class="NArialL">
               <html:text name="splitMergeLot" property="lotNumber" size="17" styleClass="txfield"/>
               </td>
       		<td width="5%">&nbsp;</td>
       		<td width="10%"><font class="NArialL">&nbsp;</font></td>
  	  		<td width="15%"><font class="NArialL">&nbsp;</td>
       		<td width="5%">&nbsp;</td>
     	  </tr>
     	   <tr>
	     		<td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
	     	</tr>
 	     	<tr>
       			<td colspan=5 align=center>
                     <a href="javascript:submitPage('<%= from%>')">
		     	<img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to search for Lots';return true" onmouseout="window.status='';return true" title="Click here to Search for Lots"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:document.splitMergeLot.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif"  onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"  width="53" height="17"></a>
				</td>
     	    </tr>
  	</table>
     </td>
 </tr>
 <tr>
     <td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
 </tr>
 <tr>
     <td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
 </tr>
 <tr>
     <td>
        <logic:equal name="showList" value="TRUE">
        <table border="0" width="100%" bordercolor="#FFFFFF" align=right>
  	   <tr>
	       <td class="NArialL">Select the Lot</td>
	   </tr>
  	   <tr>
	       <td class="NArialL"><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
	   </tr>
   	   <tr>
		  <!--td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Product Name</font></td -->
		  <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Lot No</font></td>
                  <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Current Process</font></td>
                  <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Status</font></td>
		  <td align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Actions</font></font></td>
           </tr>
 <%
        ArrayList activeLots = (ArrayList)request.getAttribute("activeLots");
        Iterator it = activeLots.iterator();
        int i = 0;
        while(it.hasNext()){

                LotView lview = (LotView)it.next();

                if((i%2) == 0){
 %>               <tr>
		     <!--td align="center" bgcolor="#DEE1E2"><font class="NArialL"></td -->
		     <td align="center" bgcolor="#DEE1E2"><font class="NArialL"><%= lview.getLotNumber()%></td>
                     <td align="center" bgcolor="#DEE1E2"><font class="NArialL"><%= lview.getCurrentProcess() %></td>
                     <td align="center" bgcolor="#DEE1E2"><font class="NArialL"><%= lview.getStatus() %></td>
		     <td align="center" bgcolor="#DEE1E2"><font class="NArialL">
                     <a href="javascript:splitLot(<%= lview.getLotID()%>, '<%= lview.getStatus() %>', '<%= lview.getLotNumber()%>')"onmouseover="window.status='Click to Split the Lot';return true" onmouseout="window.status='';return true">split</a>&nbsp;&nbsp;
                     <a href="javascript:mergeLot(<%= lview.getLotID()%>, '<%= lview.getStatus() %>', '<%= lview.getLotNumber()%>')"onmouseover="window.status='Click to Merge to the Lot';return true" onmouseout="window.status='';return true">merge</a>
		     </td>
                  </tr>

 <%
                }else{
 %>

                <tr>
 		  <!-- td align="center" bgcolor="#FFFFEE"><font class="NArialL"></td -->
		  <td align="center" bgcolor="#FFFFEE"><font class="NArialL"><%= lview.getLotNumber()%></td>
                  <td align="center" bgcolor="#FFFFEE"><font class="NArialL"><%= lview.getCurrentProcess() %></td>
                  <td align="center" bgcolor="#FFFFEE"><font class="NArialL"><%= lview.getStatus() %></td>
		  <td align="center" bgcolor="#FFFFEE"><font class="NArialL">
                     <a href="javascript:splitLot(<%= lview.getLotID()%>, '<%= lview.getStatus() %>', '<%= lview.getLotNumber()%>')" onmouseover="window.status='Click to Split the Lot';return true" onmouseout="window.status='';return true" >split</a>&nbsp;&nbsp;
                     <a href="javascript:mergeLot(<%= lview.getLotID()%>, '<%= lview.getStatus() %>', '<%= lview.getLotNumber()%>')" onmouseover="window.status='Click to Merge to the Lot';return true" onmouseout="window.status='';return true">merge</a>
		  </td>
                </tr>

 <%
                }
        i++;

        }
 %>
        </table>
  	</logic:equal>
     </td>
 </tr>
 </table>

<input type="hidden" name="lotaction" value="">
<input type="hidden" name="status" value="">
<input type="hidden" name="tempLotNumber" value="">
<input type="hidden" name="lotid" value="">
<input type="hidden" name="process" value="">

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
</html:form>
<!-- Footer starts here -->

<%@include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>
